package com.own.compoent.mq.rabbit.producer.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;

/**
 * BalanceRechargeMqConfig
 * <p>
 * 余额充值消息队列
 *
 * @author chenxueli
 * @date 2023-08-28 21:24:59
 */
@SpringBootConfiguration
public class BalanceRechargeMqConfig {

    /**
     * 声明队列
     *
     * @return 队列
     */
    @Bean
    public Queue balanceRechargeMq() {
        return new Queue("balance.recharge.queue");
    }

    /**
     * 声明exchange
     *
     * @return exchange
     */
    @Bean
    public FanoutExchange balanceRechargeMqExchange() {
        return new FanoutExchange("balance.recharge.exchange");
    }

    /**
     * 声明Binding,exchange与queue的绑定关系
     *
     * @return Binding
     */
    @Bean
    public Binding bindBalanceRecharge() {
        return BindingBuilder.bind(balanceRechargeMq()).to(balanceRechargeMqExchange());
    }

}
